package com.mialab.servlet_demo;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.GenericServlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;

@WebServlet(name = "MyGenericServlet", urlPatterns = { "/generic" }, initParams = {
		@WebInitParam(name = "driverClassName", value = "org.postgresql.Driver")})

public class MyGenericServlet extends GenericServlet {
	private static final long serialVersionUID = 1L;

	public MyGenericServlet() {
		super();
	}

	public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
		ServletConfig servletConfig = getServletConfig();
		String driverClassName = servletConfig.getInitParameter("driverClassName");
		String url = servletConfig.getInitParameter("url");
		response.setContentType("text/html");
		PrintWriter writer = response.getWriter();		
		writer.print("driverClassName:" + driverClassName);			
	}
}
